<template>
  <s-layout class="set-wrap" title="发布视频" :bgStyle="{ color: '#f7f7f7' }">
    <!-- <s-empty v-if="state.list.length === 0 && !state.loading" text="暂无常见问题" icon="/static/collect-empty.png" /> -->

    <!-- 开始代码 -->
    <view class="flex flex-col px-4 pb-4 bg-white">
      <view class="flex overflow-hidden flex-col bg-white rounded-lg">
        <!-- 商品标题 -->
        <view class="flex items-center py-2">
          <view class="text-[15px] text-[#333333] flex-none w-[5rem]"> 标题 </view>
          <uni-easyinput
            v-model="state.title"
            placeholder="标题"
            type="text"
            :inputBorder="false"
            placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
            :styles="{ disableColor: '#fff', color: '#333' }"
          >
          </uni-easyinput>
        </view>
        <u-line></u-line>

        <view class="flex flex-col gap-4 py-4 pb-0">
          <view class="text-[15px] text-[#333333] flex-none w-[5rem]"> 视频 </view>
          <s-uploader v-model:url="state.file" fileMediatype="video" limit="1" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }">
          </s-uploader>
        </view>
      </view>
    </view>

    <view class="py-5"></view>
    <view class="fixed right-0 bottom-0 left-0 p-4 bg-white">
      <view class="overflow-hidden py-3 w-full rounded-lg bg-[#0788C8] grid place-items-center" @click="publishVideo">
        <view class="font-medium text-[16px] text-[#FFFFFF]"> 发布视频 </view>
      </view>
    </view>
  </s-layout>
</template>

<script setup>
  import sheep from '@/sheep';

  const state = ref({
    title: '',
    file: '',
    list: [],
    loading: true,
  });

  onLoad(() => {});
  function publishVideo() {
    //addVideo
    let obj = {
      title: state.value.title,
      file: state.value.file,
    };
    sheep.$api.yy.addVideo(obj).then((res) => {
      if (res.code === 1) {
        uni.showToast({
          title: '发布成功,请等待审核',
          icon: 'success',
        });
        setTimeout(() => {
          //清空表单
          state.value.title = '';
          state.value.file = '';
          //返回
          uni.navigateBack({
            delta: 1,
          });
        }, 200);
      }
    });
  }
</script>

<style lang="scss" scoped></style>
